﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OxyPlot;
using OxyPlot.Series;
using System.Collections;

namespace LP1415
{
    /// <summary>
    /// grafico desenhado pela biblioteca oxyPlot
    ///</summary> 
    public partial class grafico : Form
    {
        string nome;
        ArrayList listAno;
        ArrayList listPontos;
       
        /// <summary>
        ///inicializacao da form
        /// </summary>
        /// <param name="listAno">arrayList dos valores dos anos.</param>
        /// <param name="listPontos">arrayList dos valores do y.</param>
        /// <param name="name">string com o nome que ira ser dado ao grafico</param>
        public grafico(ArrayList listAno, ArrayList listPontos, string name)
        {
            InitializeComponent();
            this.nome = name;
            this.listAno = listAno;
            this.listPontos = listPontos;

        }
        /// <summary>
        /// detalhes do grafico
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form3_Load(object sender, EventArgs e)
        {
            string str;
            float x;
            float y;
            double b;
            double b1;
            var myModel = new PlotModel
            {
                Title =this.nome
            };
            
            // myModel.Series.Add(new FunctionSeries(Math.Cos,0,10,0.1,"renu"));
            var xPoints = new LineSeries();
            for (int i = 0; i < this.listAno.Count; i++)
            {
                str = Convert.ToString(listPontos[i]);
                if ((listPontos[i] != null) && (str != ""))
                {
                b = Convert.ToDouble(this.listAno[i]);
                b1 = Convert.ToDouble(this.listPontos[i]);          
                //depois para float para poder desenhar
                x = (float)(b);
                y = (float)(b1);
                xPoints.Points.Add(new DataPoint(x, y));
            }
            }
           
            myModel.Series.Add(xPoints);
            this.plot1.Model = myModel;
        }

        private void plot1_Click(object sender, EventArgs e)
        {

        }
        /// <summary>
        ///botao sair do menu
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
        
            //exit 
            Close();
        }
        /// <summary>
        ///botao about do programa</summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void verAjudaToolStripMenuItem_Click(object sender, EventArgs e)
        {
       
            MessageBox.Show("Trabalho LP 14/15 Realizado por Bruno Rendeiro & André Simão\n\n");
        }
          
        }
    }

